package com.itheima;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/delServlet")
public class DelServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //获取请求参数id
        String id = request.getParameter("id");
        //把字符串转换成整数
        int i = Integer.parseInt(id);
        //根据id删除集合中对应的对象
        UserDao dao=new UserDao();
        dao.delUser(i);
        //转发到展示页码
        request.getRequestDispatcher("/findServlet").forward(request,response);
    }
}
